import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router);

export const constantRoutes =  [
    {
        path: '/',
        name: 'index',
        component:()=>import("../components/index.vue")   //首页
    },
    {
        path: '/login',
        name: 'login',
        component:()=>import("../components/login.vue")     //登录页
    },
    {
        path: '/main',
        name: 'main',
        component:()=>import("../components/main.vue")      //检测页面
    },
    {
        path: '/userList',
        name: 'userList',
        component:()=>import("../components/UserList.vue")  //账号管理
    },
    {
        path: '/history',
        name: 'history',
        component:()=>import("../components/history.vue")   //检测历史记录
    },


]
const createRouter = () => new Router({
    // mode: 'history', // require service support
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
    const newRouter = createRouter()
    router.matcher = newRouter.matcher // reset router
}

export default router
